<?php
class Functions_Model extends CI_Model {
	protected $table_name = '';
	
	const GETCAR_STMT = "SELECT b.brand_id, b.brand_name, m.model_id, m.model_name 
						 FROM tt_carbrand_tt b LEFT JOIN tt_carmodel_tt m
    					 ON b.brand_id = m.brand_id
						 ORDER BY b.brand_name, m.model_name";
	
	const GETCOUNTRY_STMT = "SELECT country_id, country_name 
							 FROM tt_country_tt ORDER BY country_name";
	
	const GETFUEL_STMT = "SELECT fuel_id, fuel_name FROM tt_fuel_tt ORDER BY fuel_id";
	
	public function __construct() {
		$this->load->database();
	}
	
	/*
		Get brand and model list from database
		to create a car menu list
	*/
	public function get_car() {
		$query = $this->db->query(self::GETCAR_STMT);
		return $query->result_array();
	}
	
	/*
		Get country list from database
	*/
	public function get_country() {
		$query = $this->db->query(self::GETCOUNTRY_STMT);
		return $query->result_array();
	}
	
	public function get_fuel() {
		$query = $this->db->query(self::GETFUEL_STMT);
		return $query->result_array();
	}
}
?>